package com.example.demo.controller;

import com.example.demo.annotation.Roles;
import com.example.demo.dto.ElderlyServiceAddDTO;
import com.example.demo.dto.PageDTO;
import com.example.demo.pojo.ElderlyService;
import com.example.demo.pojo.Result;
import com.example.demo.service.ElderlyServiceService;
import com.example.demo.vo.ElderlyServiceVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("service")
@Slf4j
@Tag(name = "服务接口")
@RequiredArgsConstructor
public class ElderlyServiceController {
    private final ElderlyServiceService elderlyServiceService;
    @PostMapping("/elderly")
    @Operation(summary = "建立老人和服务")
    @Roles(values = "sa")
    public Result addElderlyService(@RequestBody ElderlyServiceAddDTO elderlyServiceAddDTO) {
        log.info("{}", elderlyServiceAddDTO);
        elderlyServiceService.addElderlyService(elderlyServiceAddDTO);
        return Result.success();
    }

    @GetMapping("/elderly/{id}")
    @Operation(summary = "获取未确认老人服务信息")
    @Roles(values = "da")
    public Result<List<ElderlyServiceVO>> getElderlyService(@PathVariable Long id) {
        return Result.success(elderlyServiceService.getElderlyService(id));
    }
}
